'use strict';

myApp.controller('LoginCtrl', ['$rootScope', '$scope', '$http', '$location', 'APIServer', function ($rootScope,$scope,$http,$location,APIServer) {

	$scope.login = function () { 
		$rootScope.currentUser = null;	
/*
		$http.post(APIServer.Url.LogIn,{
              'email' : $scope.username,
              'password' : $scope.password
        })
      	.success(function(data, status, headers, config) {
			if(status === 200){
				$rootScope.currentUser = {
					fullName : response.name ? response.name : 'Nombre no disponible',
					profile : response.profile
				};
				$location.url('/');
			}else{
				
			}
		})
		.error(function(data, status, headers, config) {
			
		});*/

		$rootScope.currentUser = {
			"name" : "Ivan Lerma",
			"sessionid" : "idsess"
		};	
		$location.url('/');
	};//login()

	$rootScope.logout = function(){
		/*
		$http.post(APIServer.Url.LogOut,{
              'sessionid' : $$rootScope.currentUser.sessionid
        })
      	.success(function(data, status, headers, config) {
			if(status === 200){
				$rootScope.currentUser = {
					fullName : response.name ? response.name : 'Nombre no disponible',
					profile : response.profile
				};
				$location.url('/');
			}else{
				
			}
		})
		.error(function(data, status, headers, config) {
			
		});*/
		$rootScope.currentUser = null;	
		$location.url('/login');
		
    };

}]);
  